home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / misc / BoulderEngine.lha / source / GRAFKERNEL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-30  |  2.8 KB  |  128 lines

  1.  
  2. #include <stdio.h>
  3. #include <exec/types.h>
  4. #include <graphics/gfx.h>
  5. #include <graphics/copper.h>
  6. #include <graphics/view.h>
  7. #include <graphics/rastport.h>
  8. #include <graphics/gels.h>
  9. #include <graphics/regions.h>
  10. #include <graphics/clip.h>
  11. #include <graphics/sprite.h>
  12. #include <exec/exec.h>
  13. #include <graphics/text.h>
  14. #include <graphics/gfxbase.h>
  15. #include <graphics/gfxmacros.h>
  16. #include <hardware/dmabits.h>
  17. #include <hardware/custom.h>
  18. #include <exec/memory.h>
  19. #include <intuition/intuition.h>
  20. #define DEPTH 1L
  21. #define WIDTH 630L
  22. #define HEIGHT 400L
  23. #define VPWIDTH 630L
  24. #define VPHEIGHT 400L
  25.  
  26. #define NOT_ENOUGH_MEMORY -1000
  27. struct View view;
  28. struct ViewPort viewport;
  29. struct ColorMap *cm;
  30. struct RasInfo rasinfo;
  31. struct BitMap bitmap;
  32. struct RastPort rastport;
  33. extern struct ColorMap *GetColorMap();
  34. struct GfxBase *GfxBase;
  35. struct View *oldview;
  36. USHORT colortable[]={
  37. 0x000,0x2f5,0x44e,0x0c1,
  38. 0x999,0x445,0x999,0xd10,
  39. 0x356,0x55f,0x888,0xc57,
  40. 0x115,0x023,0xf00,0x209,
  41. 0x127,0x213,0x209,0x15f,
  42. 0x190,0x088,0x090,0xf22,
  43. 0x333,0x444,0x555,0x666,
  44. 0x777,0x888,0x999,0xaaa,
  45. 0 };
  46. UWORD *colorpalette;
  47.  
  48. pasiruosk()
  49. {
  50. LONG i,n;
  51. UBYTE *displaymem;
  52.  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L);
  53.  if (GfxBase==NULL) exit(100);
  54.  
  55.  oldview=GfxBase->ActiView;
  56.  
  57.  InitView(&view);
  58.  InitVPort(&viewport);
  59.  view.ViewPort = &viewport;
  60.  view.Modes=HIRES+LACE;
  61.  InitBitMap(&bitmap,DEPTH,WIDTH,HEIGHT);
  62.  InitRastPort(&rastport);
  63.  rastport.BitMap = &bitmap;
  64.  rasinfo.BitMap = &bitmap;
  65.  rasinfo.RxOffset = 0;      /* Kad nesimatytu pvz. */
  66.  rasinfo.RyOffset = 0;
  67.  rasinfo.Next = NULL;
  68.  
  69.  viewport.DWidth = VPWIDTH;
  70.  viewport.DHeight = VPHEIGHT;
  71.  viewport.RasInfo = &rasinfo;
  72.  viewport.DyOffset = 0;
  73.  viewport.DxOffset = 0;
  74.  viewport.Modes =HIRES + LACE; /* DUALPF , PFBA , HIRES , LACE , HAM ,SPRITES*/
  75.  cm = GetColorMap(32L);
  76.  if (cm == NULL) { exit(100); }
  77.  colorpalette = (UWORD *)cm->ColorTable;
  78.  for(i=0;i<32;i++) { *colorpalette++ = colortable[i]; }
  79.  viewport.ColorMap = cm;
  80.  for(i=0; i<DEPTH;i++) {
  81.   bitmap.Planes[i] = (PLANEPTR) AllocRaster(WIDTH,HEIGHT);
  82.   }
  83.   MakeVPort(&view,&viewport);
  84.   MrgCop(&view);
  85.   LoadView(&view);
  86.   }
  87.  
  88.  
  89. plot(x,y)
  90. LONG x,y;
  91. { Move(&rastport,x,y); Draw(&rastport,x,y); }
  92. Tekstscreen(xx,yy)
  93. SHORT xx,yy;
  94. {
  95.   rasinfo.RxOffset = xx;
  96.   rasinfo.RyOffset = yy;
  97.   MakeVPort(&view,&viewport);
  98.   MrgCop(&view);
  99.   LoadView(&view);
  100. }
  101.  
  102. /* --------------------------------------------------------------*/
  103. FreeMemory()
  104. {
  105. LONG i;
  106. LoadView(oldview);
  107. WaitTOF();
  108. for(i=0;i<DEPTH; i++) { if (bitmap.Planes[i] != NULL) {
  109.   FreeRaster(bitmap.Planes[i],WIDTH,HEIGHT);
  110.  }}
  111. if (cm != NULL) FreeColorMap(cm);
  112. FreeVPortCopLists(&viewport);
  113. FreeCprList(view.LOFCprList);
  114. CloseLibrary(GfxBase);
  115. return(0);
  116. }
  117.  
  118. SHORT galima(range)
  119. short range;
  120. {
  121. static int konst;
  122. short l=0;
  123. konst+=range;
  124. if(konst>254) {konst-=254; l=1; }
  125. return(l);
  126. }
  127.  
  128.